package com.doge.controller.admin;

import com.doge.bean.base.BaseData;
import com.doge.bean.base.BaseParam;
import com.doge.bean.base.BaseRespVo;
import com.doge.bean.pojo.user.User;
import com.doge.bean.pojo.user.UserExample;
import com.doge.service.admin.user.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @program: project2-wechat-mall
 * @description: 用户会员管理
 * @author: zhu lei
 * @create: 2021-11-29 22:49
 **/
@RestController
@RequestMapping("/admin/user")
public class UserController {
    @Autowired
    UserServiceImpl userService;

    @RequestMapping("detail")
    public BaseRespVo userListDetail(Integer id) throws Exception {
        User user = userService.userListDetail(id);
        return BaseRespVo.ok(user);
    }
    @RequestMapping("list")
    public BaseRespVo userList( String username, String mobile,Integer id, BaseParam baseParam) throws Exception {
        BaseData baseData = userService.userList(username, mobile,id, baseParam);
        return BaseRespVo.ok(baseData);
    }

    @RequestMapping("update")
    //TODO：电话号码校验
    public BaseRespVo userUpdate(@RequestBody User user) throws Exception {
        int i = userService.updateList(user);
        return BaseRespVo.ok(i);
    }
}